<template>
  <div>
    <van-tabbar-item
      v-if="this.attitude==-1"
      icon="good-job-o"
      @click="isLiking"
      style="margin-top:10px"
      :loading="btnloading"
    ></van-tabbar-item>
    <van-tabbar-item :loading="btnloading" v-if="this.attitude==1" @click="isLiking">
      <van-icon slot="icon" name="good-job" color="#e5645f" style="margin-top:10px" />
    </van-tabbar-item>
  </div>
</template>
<script>
import { liking_api, noliking_api } from "@/api/user.js";
export default {
  props: ["artId", "attitude"],
  data() {
    return {
      btnloading: false,
    };
  },
  methods: {
    async isLiking() {
      this.$emit("aa", this.attitude == -1 ? 1 : -1);
      this.btnloading = true;
      if (this.attitude == -1) {
        // 点赞
        const { data: res } = await liking_api(this.artId);
        this.$toast("点赞成功");
        // console.log(res, 1);
      } else {
        // 取消点赞
        const { data: res } = await noliking_api(this.artId);
        this.$toast("取消点赞");
        // console.log(res, 2);
      }
      this.btnloading = false;
    },
  },
};
</script>
<style lang='less' scoped>
</style>